//***********************************************************************
//	File:		Striker.cpp
//	Author:		
//	Course:		SGP 1405
//	Purpose:	
//***********************************************************************
//***********************************************************************
//	Purposfully left blank for all comments regarding this file 
//	
//	
//	
//***********************************************************************



#include "Striker.h"

Striker::Striker(float posX, float posY)
{
	SetAcceleration({ 0 , 0 });
	SetAttackCDL(2); 
	SetAttackRange(3); 
	SetBlinkCDL(2);
	SetBlinkDistance(150);
	SetBlinkTimer(0);
	SetConfuseCDL(0);
	SetConfuseTimer(0);
	SetDamage(40);
	SetDynamicFrictionCoefficient(.4f);
	SetHealth(60);
	//SetImage(); 
	SetKnockbackCDL(3); 
	SetKnockBackTimer(0); 
	SetMass(30);
	SetMaxHealth(60); 
	SetMaxSpeed(200);
	SetPassable(false);
	SetPosition(SGD::Point{ posX, posY }); 
	SetRootCDL(4); 
	SetRootTimer(0); 
	SetRotation(0);
	SetSize(SGD::Size{ 32, 32 }); 
	SetSpeed(0); 
	SetStaticFrictionCoefficient(.7f);
	//SetTakeDamage() particle emitter
	SetTarget(nullptr); 
	SetValue(ENT_STRIKER);
	SetVelocity(SGD::Vector{ 0, -1 }); 

	m_hImage = SGD::GraphicsManager::GetInstance()->LoadTexture(
		L"reources/graphics/Striker.png");


}

void Striker::Update(float dt)
{

	if (m_bMove == true)
	{

		if (pTarget)
		{
			SGD::Vector vec = pTarget->GetPosition() - GetPosition();
			vec.Normalize();
			vec *= 75.0f;

			SetPosition(GetPosition() + vec * dt);
		}


		if (pTarget->GetPosition().x - this->GetPosition().x <= 8 && pTarget->GetPosition().y - this->GetPosition().y <= 8)
			Attack(dt);

		if (m_fAttackCDL <= 0)
			m_fAttackCDL -= dt;

	}

	//Last line of function
	Entity::Update(dt); 
}

void Striker::Render()
{
	SGD::GraphicsManager::GetInstance()->DrawTexture(m_hImage, GetPosition(), 0.0, SGD::Vector(0, 0), SGD::Color(), SGD::Size(64, 64));
}

void Striker::HandleCollision(const IEntity* pOther)
{
	Entity::HandleCollision(pOther);
}

void Striker::HandleEvent()
{

}

SGD::Rectangle Striker::GetRect() const
{
	return SGD::Rectangle{}; 
}

void Striker::ModifyHealth(float hpAmount)
{
	m_fTotalHP -= hpAmount;
}

void Striker::ApplyFriction(float dt)
{

}

void Striker::Attack(float dt)
{
	if (pTarget->GetPosition().x - this->GetPosition().x <= 8 && pTarget->GetPosition().y - this->GetPosition().y <= 8)
	{

		if (m_fAttackCDL <= 0)
		{

			GetDamage();
			m_fAttackCDL = 10;

		}

	}
}

void Striker::Move(void)
{
	if (pTarget->GetPosition().x - this->GetPosition().x <= 200 && pTarget->GetPosition().y - this->GetPosition().y <= 200)
		m_bMove = true;
}

// Striker Specific
void Striker::Blink()
{

}